package com.bjsxt.common.action;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bjsxt.common.util.RegexUtil;
import com.bjsxt.common.util.VerifyCodeUtils;
@Component("commonAction")
@RequestMapping("common")
public class CommonAction
{
	@Resource
	private VerifyCodeUtils codeUtil;
	@Resource
	private RegexUtil regexUtil;
	@RequestMapping("/getCode.htm")
	public String returnCode(HttpServletResponse resp,HttpServletRequest req)
	{
		String code=regexUtil.getRandom(4);
		System.out.println("验证码是------------------"+code);
		req.getSession().setAttribute("code", code);
		try
		{
			VerifyCodeUtils.outputImage(100, 50, resp.getOutputStream(), code);
		} catch (IOException e)
		{
			e.printStackTrace();
		}	
		return null ; 
	}
}
